package edu.uoc.tdp.pac4.server.connexiomanteniment.db;

import java.sql.Statement;
import java.sql.SQLException;
import java.sql.ResultSet;
import java.util.Vector;

import edu.uoc.tdp.pac4.server.connexiomanteniment.exceptions.*;


public class GestorUniversitats extends Gestor {
	public GestorUniversitats() {}
	
	public Vector<String> getUniversitats() throws ExceptionServer {
		Statement st = null; ResultSet rs = null;
 		Vector<String> v = new Vector<String>(); 
		connect();
		try {
			String query = "SELECT DISTINCT universitat FROM estudiant ORDER BY universitat ASC";
		 	st = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
		 	rs = st.executeQuery(query);	
	 		while (rs.next()) { v.add(rs.getString(1)); }
    	} catch (SQLException e) { ManageSQLException(e); } 
		finally { try { rs.close();	 st.close(); disconnect(); } catch(Exception e){ throw new ExceptionServer(ExceptionServer.SERVER_DB_UNEXPECTED_ERROR); } }
		return v;
	}
}
	
